<?php
//$_SESSION['mode']='';
if ($_GET['type']=='all') $_SESSION['mode']='';
if ($_GET['type']=='audio') $_SESSION['mode']='.mp3';
if ($_GET['type']=='video') $_SESSION['mode']='/';

if ($_POST['add']!='')
{
	$cmd="SELECT * FROM `select`";
	$excute=mysql_query($cmd);
	$author=''; $artist='';
	while($info=mysql_fetch_array($excute,MYSQL_ASSOC))
	{
	    if (isset($_POST['author'.$info['select_id']])) $author.=$info['select_id'].'-';
		if (isset($_POST['artist'.$info['select_id']])) $artist.=$info['select_id'].'-';
	}
	$songstatus=$_POST['songstatus'];
	$songname=$_POST['songname'];
	$songtype=$_POST['songtype'];
	$linkvideo=$_POST['linkvideo'];
	$ud1=''; $ud2='';
	if ($linkvideo=='')
	{
			if ($_FILES["fileaudio"]["type"] == "audio/mp3")
   				{
  				if ($_FILES["fileaudio"]["error"] > 0) echo "Return Code: " . $_FILES["fileaudio"]["error"] . "<br />";
  				else
					{
         			chdir('/home/cailuong/public_html/data');
		 			$newname='cailuongso.com-'.time().'-'.rand(1,1000000).'-'.format(convert($songname)).'.mp3';
         			move_uploaded_file($_FILES["fileaudio"]["tmp_name"],$newname);
					$getID3 = new getID3;
					$mediainfo = $getID3->analyze($newname);
					$sizef=$mediainfo['filesize'];
	                $bitrate=$mediainfo['bitrate'];
	                $playtime=$mediainfo['playtime_string'];					
					$ud1="`media_filesize`,`media_bitrate`,`media_playtime`,";
					$ud2="'$sizef','$bitrate','$playtime',"; 
		 			$linkvideo=$newname;
  					}
				}
			else echo "Định dạng file audio bạn up lên không đúng chuẩn .mp3, vui lòng thử lại !";	
	}
	
	
		if ((($_FILES["file"]["type"] == "image/gif")
			|| ($_FILES["file"]["type"] == "image/jpeg")
			|| ($_FILES["file"]["type"] == "image/jpg")
			|| ($_FILES["file"]["type"] == "image/png")))
  		{
  			if ($_FILES["file"]["error"] > 0) echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
  		else{
         		chdir('/home/cailuong/public_html/beta/data/image/video/');
		 		$newname=rand(1,100000).time().$_FILES["file"]["name"];
         		move_uploaded_file($_FILES["file"]["tmp_name"],$newname);
		 		$linkimg='data/image/video/'.$newname;
  			}
	}
	$info=$_POST['info'];
	$time=time();
	$tag=tag($songname).','.tag(convert($songname));
	if ($artist=='') $artist='150-'; 
	if ($author=='') $author='150-';	
	$cmd="INSERT INTO `media` (".$ud1." `media_artist`,`media_author`,`media_name`,`media_cat`,`media_link`,`media_img`,`media_poster`,`media_lyric`,`media_lyric_poster`,`media_tag`,`media_time`,`media_info`)
VALUES (".$ud2."'$artist','$author','$songname','$songtype','$linkvideo','$linkimg','233','$info','233','$tag','$time','$songstatus')";
	mysql_query($cmd);	
	// CREAT MD5 & HASH CODE
	$cmd="SELECT * FROM media ORDER BY media_id DESC LIMIT 0,1";
	$info=mysql_fetch_assoc(mysql_query($cmd));
	$hashcode=hashencode($info['media_id']);
	$md5=md5($info['media_id'].'memhuynh');
	$cmd="UPDATE `media` SET media_hash='".$hashcode."',media_md5='".$md5."' WHERE media_id=".$info['media_id'];
	mysql_query($cmd);
	$_POST['add']='';
	echo 'Đã bổ sung thêm bài hát này !';
	echo '<div id="pre"><div class="buttons"><a href="/mem/?menu=select&act=add" class="button">Thêm nữa</a></div></div><div id="next"><div class="buttons"><a href="/mem/?menu=select" class="button">Quay lại</a></div></div>';
} else
if ($_POST['edit']!='')
{
	$artist='';$author='';
	$cmd="SELECT * FROM `select`";
	$excute=mysql_query($cmd);
	while($info=mysql_fetch_array($excute,MYSQL_ASSOC))
	{
	    if (isset($_POST['author'.$info['select_id']])) $author.=$info['select_id'].'-';
		if (isset($_POST['artist'.$info['select_id']])) $artist.=$info['select_id'].'-';
	}
	
	$songname=$_POST['songname'];
	$songtype=$_POST['songtype'];
	$songstatus=$_POST['songstatus'];
	$selectalbum=$_POST['selectalbum'];
	$linkimg='';
	$linkvideo=$_POST['linkvideo'];
	$time=time();
	if ($_FILES["fileaudio"]["type"] == "audio/mp3"){
  			if ($_FILES["fileaudio"]["error"] > 0) echo "Return Code: " . $_FILES["fileaudio"]["error"] . "<br />";
  		else{
         		chdir('/home/cailuong/public_html/data');
		 		$newname='cailuongso.com-'.time().'-'.format(convert($songname)).'.mp3';
         		move_uploaded_file($_FILES["fileaudio"]["tmp_name"],$newname);
				$getID3 = new getID3;
			    $mediainfo = $getID3->analyze($newname);
				$sizef=$mediainfo['filesize'];
	            $bitrate=$mediainfo['bitrate'];
	            $playtime=$mediainfo['playtime_string'];
				$update="`media_filesize`='$sizef',`media_bitrate`='$bitrate',`media_playtime`='$playtime',";				
				$cmd="SELECT * FROM media WHERE media_id=".$_GET['edit'];
				$rmf=mysql_fetch_assoc(mysql_query($cmd));
				//unlink($rmf['media_link']);  
				$linkvideo=$newname;
				echo 'Upload audio thành công ! ';
  			}
	}

		if ((($_FILES["file"]["type"] == "image/gif")
			|| ($_FILES["file"]["type"] == "image/jpeg")
			|| ($_FILES["file"]["type"] == "image/jpg")
			|| ($_FILES["file"]["type"] == "image/png")))
  		{
  			if ($_FILES["file"]["error"] > 0) echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
  		else{
         		chdir('/home/cailuong/public_html/beta/data/image/video/');
		 		$newname=rand(1,100000).time().$_FILES["file"]["name"];
         		move_uploaded_file($_FILES["file"]["tmp_name"],$newname);
				$linkimg='data/image/video/'.$newname;
				echo 'Upload ảnh thành công ! ';
  			}
	   }
	if ($linkimg=='') $wlinkimg=''; else $wlinkimg='media_img="'.$linkimg.'",';
	if ($linkvideo=='') $wlinkvideo=''; else $wlinkvideo='media_link="'.$linkvideo.'",';
	$info=$_POST['info'];
	$tag=tag($songname).','.tag(convert($songname));
	if ($artist=='') $artist='150-'; 
	if ($author=='') $author='150-';
	$albumins='media_album='.$selectalbum.',';
	$cmd="UPDATE `media` SET ".$update."media_artist='$artist',media_author='$author',media_name='$songname',
	media_cat='$songtype',".$wlinkvideo.$wlinkimg."media_lyric='$info',".$albumins."media_lyric_poster='233',media_tag='$tag',media_time='$time',media_info='$songstatus' ". "WHERE media_id=".$_GET['edit'];
    mysql_query($cmd);
	$_POST['submit']='';
	echo 'Đã chỉnh sửa thông tin bài hát này thành công !';
	echo '<div id="pre"><div class="buttons"><a href="/mem/?menu=select&act=add" class="button">Thêm nữa</a></div></div><div id="next"><div class="buttons"><a href="/mem/?menu=select" class="button">Quay lại</a></div></div>';
} else
{
if (isset($_GET['act']))
{
echo '<div class="selecttitle"><a><b>THÊM BÀI HÁT MỚI</b></a></div><br/>
	
	<form method="post" enctype="multipart/form-data">
	<table border="0">
	<tr>
    <td width="90px"><div class="selecttitle"><a>Tình trạng</a></div></td>
    <td><div class="selecttitle"><a><select name="songstatus">';
		echo '<option value="0">Chưa có dữ liệu</option>
		<option value="1">Còn thiếu dữ liệu</option>
		<option value="2">Dữ liệu đã đầy đủ</option>';		
	echo'</select></a></div></td>
    </tr>
    <tr>
    <td width="90px"><div class="selecttitle"><a>Tên bài hát</a></div></td>
    <td><div class="selecttitle"><a><input name="songname" type="text"/></a></div></td>
    </tr>
	<tr>
    <td><div class="selecttitle"><a>Chọn album</a></div></td>
    <td><div class="selecttitle"><a><select name="selectalbum">';
	$cmd="SELECT * FROM `album` ORDER BY `album_id` DESC";	
	echo '<option value="0">Không nằm trong album</option>';
	$excute=mysql_query($cmd);
	while ($info=mysql_fetch_array($excute,MYSQL_ASSOC))
	{
		$value=$info['album_id'];
		echo '<option value="'.$value.'">'.$info['album_name'].'</option>';
	}
	echo'</select></a></div></td>
    </tr>
    <tr>
    <td><div class="selecttitle"><a>Thể loại</a></div></td>
    <td><div class="selecttitle"><a><select name="songtype">';
	$cmd="SELECT * FROM `cat`";	
	$excute=mysql_query($cmd);
	while ($info=mysql_fetch_array($excute,MYSQL_ASSOC))
	{
		$value=$info['cat_id'];
		echo '<option value="'.$value.'">'.$info['cat_name'].'</option>';
	}
	echo'</select></a></div></td>
    </tr>
    <tr>
    <td><div class="selecttitle"><a>Link Video</a></div></td>
    <td><div class="selecttitle"><a><input name="linkvideo" type="text"/></a></div></td>
    </tr>
    <tr>
    <td><div class="selecttitle"><a>Upload Audio</a></div></td>
    <td><div class="selecttitle"><a><input type="file" name="fileaudio"</a></div></td>
    </tr>
	</table>	
	<div class="selecttitle"><a>Tải ảnh video lên &nbsp;&nbsp;<input type="file" name="file" id="file"/><a>
	<br/>(Chỉ dùng cho ảnh của Video. Kích thước ảnh không <br/> quá 2MB, định dạng cho phép:jpg,jpeg,png,gif )
	</div>
	<div class="selecttitle"><a><b>Lời nhạc</b> <br/>Lưu ý: Nếu muốn xuống dòng. Vui lòng gõ thêm từ <br/> "< br />" vào sau dấu chấm cuối dòng.Giữa các ký tự <br/>trong từ đó không được có khoảng trắng<br/><br/><textarea name="info"></textarea><a></div>
	<input type="submit" class="buttonclick" value="Lưu" name="add"/>
	
	';
	echo'
	<div id="authorbox" style="width:200px; height: 400px;">
	<b>HỘP CHỌN SOẠN GIẢ</b>';
	$cmd="SELECT * FROM `select` WHERE (select_type=3) OR (select_type=2)";
	$excute=mysql_query($cmd);
	echo '<div class="listbox">';	
	while($info=mysql_fetch_array($excute,MYSQL_ASSOC))
	{
echo '<div class="listitem2" authorid="'.$info['select_id'].'"><input type="checkbox"  name="'.'author'.$info['select_id'].'"  id="box2'.$info['select_id'].'" /><a>'.$info['select_art'].'</a></div>';
	}
	echo'</div></div>
	<div id="artistbox" style="width:200px; height:440px;">
	<b>HỘP CHỌN NGHỆ SĨ</b>';
	$cmd="SELECT * FROM `select` WHERE (select_type=3) OR (select_type=1) ORDER BY `select_art` ASC";
	$excute=mysql_query($cmd);
	echo '<div class="listbox">';	
	while($info=mysql_fetch_array($excute,MYSQL_ASSOC))
	{
echo '<div class="listitem1" artistid="'.$info['select_id'].'"><input type="checkbox" name="'.'artist'.$info['select_id'].'"  id="box1'.$info['select_id'].'" /><a>'.$info['select_art'].'</a></div>';
	}
	
	echo'</div>
	</div>
	</form>';
			
}
else
if (isset($_GET['edit'])){
	$edit=$_GET['edit'];
	$sql="SELECT * FROM `media` WHERE media_id=".$edit;
	$info=mysql_fetch_assoc(mysql_query($sql));
	$link=$info['media_link'];
	if ($info['media_author']=='') $info['media_author']='0';
	if ($info['media_artist']=='') $info['media_artist']='0';
	
	$authorarray=encode($info['media_author']);
	$artistarray=encode($info['media_artist']);	
	$imagelink=$info['media_img'];
	$audiocheck=false;
	$videocheck=false;
	if (substr($link,strlen($link)-3,strlen($link))=='mp3'){$audiocheck=true; $linv='';}else
	{$linkv=$link; $videocheck=true;} 
	echo '<div class="selecttitle"><a><b>SỬA BÀI HÁT '.$info['media_name'].'</b></a></div><br/>
	<form method="post" enctype="multipart/form-data">
	<table border="0">
	<tr>
    <td width="90px"><div class="selecttitle"><a>Tình trạng</a></div></td>
    <td><div class="selecttitle"><a><select name="songstatus">';
	
	$cmd="SELECT * FROM `media` WHERE media_id=".$_GET['edit'];	
	$row=mysql_fetch_assoc(mysql_query($cmd));
	if ($row['media_info']==0) $s0='selected';
	if ($row['media_info']==1) $s1='selected';
	if ($row['media_info']==2) $s2='selected';

		echo '<option value="0" '.$s0.'>Chưa có dữ liệu</option>
		<option value="1" '.$s1.'>Còn thiếu dữ liệu</option>
		<option value="2" '.$s2.'>Dữ liệu đã đầy đủ</option>';		
	echo'</select></a></div></td>
    </tr>	
    <tr>
    <td width="90px"><div class="selecttitle"><a>Tên bài hát</a></div></td>
    <td><div class="selecttitle"><a><input name="songname" value="'.$info['media_name'].'" type="text"/></a></div></td>
    </tr>
	
	<tr>
    <td><div class="selecttitle"><a>Chọn album</a></div></td>
    <td><div class="selecttitle"><a>
	<select name="selectalbum">';
	$cmd="SELECT * FROM `album` ORDER BY `album_id` DESC";	
	echo '<option value="0">Không nằm trong album</option>';
	$excute=mysql_query($cmd);
	while ($rows=mysql_fetch_array($excute,MYSQL_ASSOC))
	{
		$value=$rows['album_id'];
		if ($value==$info['media_album']) $values="selected"; else $values='';
		echo '<option value="'.$value.'" '.$values.'>'.$rows['album_name'].'</option>';
	}
	echo'</select>
	</a></div></td>
    </tr>
	
    <tr>
    <td><div class="selecttitle"><a>Thể loại</a></div></td>
    <td><div class="selecttitle"><a><select name="songtype">';
	$cmd="SELECT * FROM `cat`";	
	$excute=mysql_query($cmd);
	while ($row=mysql_fetch_array($excute,MYSQL_ASSOC))
	{
		$value=$row['cat_id'];
		if ($row['cat_id']==$info['media_cat']) $values="selected"; else $values='';
		echo '<option value="'.$value.'" '.$values.'>'.$row['cat_name'].'</option>';
	}
	echo'</select></a></div></td>
    </tr>
    <tr>
    <td><div class="selecttitle"><a>Link Video</a></div></td>
    <td><div class="selecttitle"><a><input name="linkvideo" type="text" value="'.$linkv.'"/></a></div></td>
    </tr>
    </table>';
	
	if ($videocheck)
	{
	echo '
<script type="text/javascript" type="text/javascript" src="../template/script/js/player.js"></script>
<div id="mediaspace"></div>';
echo"
<script type='text/javascript'>
  jwplayer('mediaspace').setup({
    'flashplayer': 'http://beta.cailuongso.com/media/player.swf',
    'file': '".$info['media_link']."',
    'controlbar': 'bottom',
	'autostart': 'true',
	'plugins': 'hd-1',
    'width': '305',
    'height': '195'
  });
</script>";
	}
	echo'
    <div class="selecttitle"><a>Upload Audio &nbsp <input type="file" name="fileaudio"/></a></div>';
    if ($audiocheck)
	{
	echo'
<script type="text/javascript" type="text/javascript" src="../template/script/js/player.js"></script>
<div id="mediaspace"></div>';
echo"
<script type='text/javascript'>
  jwplayer('mediaspace').setup({
    'flashplayer': 'http://beta.cailuongso.com/media/player.swf',
    'file': 'http://cailuongso.com/data/".$info['media_link']."',
    'controlbar': 'bottom',
	'autostart': 'true',
    'width': '295',
    'height': '22'
  });
</script>";	
	}
	if ($videocheck)
	{
	echo'<br/>';
	echo  '<img src="http://beta.cailuongso.com/'.$imagelink.'" width="100px"/><br/>
	<br/>';
	}
echo'<div class="selecttitle"><a>Upload ảnh video &nbsp;<input type="file" name="file" id="file"/><a>
	<br/>(Chỉ dùng cho ảnh của Video. Kích thước ảnh không <br/> quá 2MB, định dạng cho phép:jpg,jpeg,png,gif )
	</div>
	<div class="selecttitle"><a><b>Lời nhạc</b> <br/>Lưu ý: Nếu muốn xuống dòng. Vui lòng gõ thêm từ <br/> "< br />" vào sau dấu chấm cuối dòng.Giữa các ký tự <br/>trong từ đó không được có khoảng trắng<br/><br/><textarea name="info">'.$info['media_lyric'].'</textarea><a></div>
	<input type="submit" class="buttonclick" value="Sửa" name="edit"/>
	';
	echo'
	<div id="authorbox" style="width:200px; height: 400px;">
	<b>HỘP CHỌN SOẠN GIẢ</b>';
	$cmd="SELECT * FROM `select` WHERE (select_type=3) OR (select_type=2) ORDER BY `select_art` ASC";
	$excute=mysql_query($cmd);
	echo '<div class="listbox">';	
	while($info=mysql_fetch_array($excute,MYSQL_ASSOC))
	{
	   if (in_array($info['select_id'],$authorarray)) $valuep=' checked '; else $valuep='';
echo '<div class="listitem2" authorid="'.$info['select_id'].'"><input type="checkbox"'.$valuep.' name="'.'author'.$info['select_id'].'"  id="box2'.$info['select_id'].'" /><a>'.$info['select_art'].'</a></div>';
	}
	echo'</div></div>
	
	<div id="artistbox" style="width:200px; height:440px;">
	<b>HỘP CHỌN NGHỆ SĨ</b>';
	$cmd="SELECT * FROM `select` WHERE (select_type=3) OR (select_type=1) ORDER BY `select_art` ASC";
	$excute=mysql_query($cmd);
	echo '<div class="listbox">';	
	while($info=mysql_fetch_array($excute,MYSQL_ASSOC))
	{
		if (in_array($info['select_id'],$artistarray)) $valuep=' checked '; else $valuep='';
echo '<div class="listitem1" artistid="'.$info['select_id'].'"><input type="checkbox"'.$valuep.' name="'.'artist'.$info['select_id'].'"  id="box1'.$info['select_id'].'" /><a>'.$info['select_art'].'</a></div>';
	}
	
	echo'</div>
	</div>
	</form>';
			
}
else
{
if (isset($_GET['del']))
{
    chdir('/home/cailuong/public_html/data');
	$sql="SELECT * FROM `media` WHERE media_id=".$_GET['del'];
	$info=mysql_fetch_array(mysql_query($sql));
	if ($info['media_link']!='') unlink($info['media_link']); 
	$sql="DELETE FROM `media` WHERE media_id=".$_GET['del'];
	mysql_query($sql);
}
if (isset($_GET['x']))
{
	$x=$_GET['x'];
	$decy=$x-15;
	if ($decy<0) $decy=0;
	$incy=$x+15;
} else {$x=0; $decy=0; $incy=15;}
echo '<div id="next"><div class="buttons"><a href="/mem/?menu=media&x='.$incy.'" class="button">Tiến tới</a></div></div>
<div id="pre"><div class="buttons"><a href="/mem/?menu=media&x='.$decy.'" class="button">Lùi lại</a></div></div>';
?>
<div id="space"><div class="buttons"><a href="?menu=media&act=add" class="button add">Thêm</a></div></div>
<div id="search">
<form method="post" action="<?php if (isset($_GET['search'])) echo $_SERVER['REQUEST_URI']; else echo $_SERVER['REQUEST_URI'].'&search=keyword'; ?>">
<input type="text" name="tukhoa" autocomplete="off" class="search" value="Nhập nội dung cần tìm"  onblur="if(this.value=='') this.value='Nhập nội dung cần tìm';" onFocus="if(this.value=='Nhập nội dung cần tìm') this.value='';" />  	 

</form></div>
<div id="videopress"><div class="buttons"><a href="/mem/?menu=media&type=video" class="button">Video</a></div></div>
<div id="audiopress"><div class="buttons"><a href="/mem/?menu=media&type=audio" class="button">Audio</a></div></div>
<div id="allpress"><div class="buttons"><a href="/mem/?menu=media&type=all" class="button">Tất cả</a></div></div>


<?php
echo '
<div id="view">
<table width="775" border="1" class="view" cellpadding="10" cellspacing="0">	
  <th width="30px"><a href="';
  if (isset($_GET['sortid']))
  {
      $url=$_SERVER['REQUEST_URI'];
	  if ($_GET['sortid']=='up') echo str_replace("up", "down",$url); else
	  echo str_replace("down", "up",$url);
  } else
  echo '?menu=media&sortid=up';
  echo'">ID</a></th>
  <th><a href="';
  if (isset($_GET['sortsong']))
  {
      $url=$_SERVER['REQUEST_URI'];
	  if ($_GET['sortsong']=='up') echo str_replace("up", "down",$url); else
	  echo str_replace("down", "up",$url);
  } else
  echo '?menu=media&sortsong=up';
  echo'">Tên bài hát</a></th>
  <th width="35px">Type</th>
  <th width="40px">Size</th>
  <th width="40px">Bitrate</th>
  <th width="40px">Time</th>
  <th width="80px">Poster</th>
  <th width="10px">Status</th>
  <th width="10px">Edit</th>
  <th width="10px">Del</th>';
  $sqlsortsong='';
  $sqlsortid='';
  if ((isset($_GET['sortid'])) || (isset($_GET['sortsong'])))
  {
      if ($_GET['sortid']=='up') $sqlsortid=' ORDER BY `media_id` ASC ';
	  if ($_GET['sortid']=='down') $sqlsortid=' ORDER BY `media_id` DESC ';
	  if ($_GET['sortsong']=='up') $sqlsortsong=' ORDER BY `media_name` ASC ';
	  if ($_GET['sortsong']=='down') $sqlsortsong=' ORDER BY `media_name` DESC ';	  
  }
  if (isset($_GET['search'])) $sql="SELECT * FROM `media` WHERE media_tag LIKE '%".$_POST['tukhoa']."%' ".$sqlsortid.$sqlsortsong; else
  if ((isset($_GET['sortid'])) || (isset($_GET['sortsong']))) 
	$sql='SELECT * FROM `media` '.$sqlsortid.$sqlsortsong.' AND media_link LIKE %"'.$_SESSION['mode'].'"% LIMIT '.$x.',15';
	else $sql='SELECT * FROM `media` WHERE media_link LIKE "%'.$_SESSION['mode'].'%" ORDER BY `media_id` DESC LIMIT '.$x.',15';
	//echo $sql;
	//die();
	$excute=mysql_query($sql);
	$excutetmp=mysql_query($sql);
	sql2();	 
	  while ($row=mysql_fetch_array($excute,MYSQL_ASSOC))
	  {
	      $dem=strlen($row['media_link']);
		  (substr($row['media_link'],$dem-3,3)=='mp3')?$ext='audio':$ext='video';
		  echo '<tr><td>';
		  if ($ext=='audio') echo ' <a href="http://beta.cailuongso.com/download.php?id='.md5($row['media_id'].'memhuynh').'">'.$row['media_id'].'<a/>'; else
		  echo $row['media_id'];
		  echo '</td>';
		  echo '<td>'.$row['media_name']; echo '</td>';
		  echo '<td>'.$ext.'</td>';
		  echo '<td>'.round($row['media_filesize']/(1024*1024),2).'</td>';		  
		  echo '<td>'.round($row['media_bitrate']/1000,0).'</td>';
		  echo '<td>'.$row['media_playtime'].'</td>';
		  $cmd="SELECT * FROM `user` WHERE userid=".$row['media_poster'];
		  $info=mysql_fetch_assoc(mysql_query($cmd));
		  echo '<td>'.$info['username'].'</td>';		
		  if  ($row['media_info']==0) echo '<td class="redcolor"></td>'; else
		  if  ($row['media_info']==1) echo '<td class="yellowcolor"></td>'; else
		  if  ($row['media_info']==2) echo '<td class="bluecolor"></td>';
		  
echo '<td><div class="buttons"><a class="button flag" href="?menu=media&edit='.$row['media_id'].'">Sửa</a></div></td>';
echo '<td><div class="buttons"><a class="button delete" href="?menu=media&del='.$row['media_id'].'">Xóa</a></div></td></tr>';
	  } 
	
	  sql();
echo '</table></div>';
}
}?>